<template>
  <view v-if="show" class="popup-mask popup-fade">
    <view class="popup-container">
      <view class="popup-header">
        <text class="popup-title">{{ popupTitle }}</text>
        <text class="popup-close" @click="$emit('close')">×</text>
      </view>
      <scroll-view scroll-y class="popup-content" :scroll-top="scrollTop">
        <text v-if="type === 'service'">【用户服务协议占位内容】\n1. 本协议为示例内容...\n2. 你可以在此处粘贴正式协议文本。</text>

      </scroll-view>
      <button class="popup-btn" @click="onAgree">同意并继续</button>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    show: Boolean,
    type: String
  },
  data() {
    return {
      scrollTop: 0
    }
  },
  computed: {
    popupTitle() {
      return this.type === 'service' ? '用户服务协议及隐私政策' : '';
    }
  },
  methods: {
    onAgree() {
      this.$emit('agree');
    }
  },
  watch: {
    show(val) {
      if (!val) this.scrollTop = 0;
    }
  }
}
</script>

<style scoped>
.popup-mask {
  position: fixed;
  left: 0; top: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.popup-fade {
  animation: popupFadeIn 0.3s;
}
@keyframes popupFadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
.popup-container {
  width: 600rpx;
  background: #fff;
  border-radius: 24rpx;
  overflow: hidden;
  box-shadow: 0 8rpx 32rpx rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
}
.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 32rpx 32rpx 0 32rpx;
}
.popup-title {
  font-size: 32rpx;
  color: #333;
  font-weight: bold;
}
.popup-close {
  font-size: 40rpx;
  color: #999;
  cursor: pointer;
}
.popup-content {
  max-height: 500rpx;
  padding: 32rpx;
  font-size: 26rpx;
  color: #444;
  overflow-y: auto;
  white-space: pre-line;
}
.popup-btn {
  margin: 32rpx;
  background: #00B386;
  color: #fff;
  font-size: 30rpx;
  border-radius: 16rpx;
  border: none;
}
</style> 